package com.wisewin.circle.util;

import java.util.List;

public class PageObjectUtil {

    public <T> PageInfo<T> savePageObject(long count, List list, PageUtil pageUtil) {
        PageInfo<T> page = new PageInfo<T>();
        long totalPage = 0;
        long pageSize = pageUtil.getPageSize();
        if (count % pageSize == 0) {
            totalPage = count / pageSize;
        } else {
            totalPage = count / pageSize + 1;
        }

        page.setRecords(list);
        page.setTotal(count);
        page.setSize(pageUtil.getPageSize());
        page.setCurrent(pageUtil.getPageNo());
        page.setPages(totalPage);
        return page;
    }
}
